﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DLV.Data.Entities;
using DLV.FrameWork;
using DLV.Library.Utilities;

namespace DLV.BackEnd.Pages
{
    public partial class BangChietTinh : AdminPageBase
    {
        
        #region Khai Bao
        protected List<CalculatorInfo> TicketAirs = new List<CalculatorInfo>();
        protected decimal TotalTicketAirPrices = 0;
        protected decimal TotalTicketAirPricesAdults = 0;
        protected decimal TotalTicketAirPricesChild = 0;
        protected decimal TotalTicketAirPricesBaby = 0;
        protected decimal TotalVatAir = 0;

        protected List<CalculatorInfo> TicketCars = new List<CalculatorInfo>();
        protected decimal TotalTicketCarPrices = 0;
        protected decimal TotalTicketCarPricesAdults = 0;
        protected decimal TotalTicketCarPricesChild = 0;
        protected decimal TotalVatCar = 0;

        protected List<CalculatorInfo> TicketStations = new List<CalculatorInfo>();
        protected decimal TotalTicketStationPrices = 0;
        protected decimal TotalTicketStationPricesAdults = 0;
        protected decimal TotalTicketStationPricesChild = 0;
        protected decimal TotalTicketStationPricesBaby = 0;
        protected decimal TotalVatStation = 0;

        protected List<CalculatorInfo> RestaurantList = new List<CalculatorInfo>();
        protected decimal TotalMenuPrices = 0;
        protected decimal TotalMenuAdults = 0;
        protected decimal TotalMenuChild = 0;
        protected decimal TotalMenuBaby = 0;
        protected decimal TotalVatRestaurant = 0;

        protected List<CalculatorInfo> TicketHotel = new List<CalculatorInfo>();
        protected decimal TotalTicketHotelPrices = 0;
        protected decimal TotalTicketHotelPricesAdults = 0;
        protected decimal TotalTicketHotelPricesChild = 0;
        protected decimal TotalTicketHotelPricesBaby = 0;
        protected decimal TotalVatHotel = 0;

        protected List<CalculatorInfo> TicketShip = new List<CalculatorInfo>();
        protected decimal TotalTicketShipPrices = 0;
        protected decimal TotalTicketShipPricesAdults = 0;
        protected decimal TotalTicketShipPricesChild = 0;
        protected decimal TotalTicketShipPricesBaby = 0;
        protected decimal TotalVatShip = 0;

        public List<CalculatorInfo> ServiceList= new List<CalculatorInfo>();
        protected decimal TotalDVKPrices = 0;
        protected decimal TotalDVKAdults = 0;
        protected decimal TotalDVKChild = 0;
        protected decimal TotalDVKBaby = 0;
        protected decimal TotalVatService = 0;

        protected List<CalculatorInfo> TravelGuideCashs = new List<CalculatorInfo>();
        protected decimal TotalTravelGuidePrices = 0;
        protected decimal TotalTravelGuidePricesAdults = 0;
        protected decimal TotalTravelGuidePricesChild = 0;
        protected decimal TotalVatTravelGuide = 0;

        protected List<CalculatorInfo> InsuranceList = new List<CalculatorInfo>();
        protected decimal TotalInsurancePrices = 0;
        protected decimal TotalInsurancePricesAdults = 0;
        protected decimal TotalInsurancePricesChild = 0;
        protected decimal TotalInsurancePricesBaby = 0;
        protected decimal TotalVatInsurance = 0;

        protected List<CalculatorInfo> VisaList = new List<CalculatorInfo>();
        protected decimal TotalVisaPrices = 0;
        protected decimal TotalVisaAdults = 0;
        protected decimal TotalVisaChild = 0;
        protected decimal TotalVisaBaby = 0;
        protected decimal TotalVatVisa = 0;

        protected List<CalculatorInfo> GiftsList = new List<CalculatorInfo>();
        protected decimal TotalGiftsPrices = 0;
        protected decimal TotalGiftsPricesAdults = 0;
        protected decimal TotalGiftsPricesChild = 0;
        protected decimal TotalGiftsPricesBaby = 0;
        protected decimal TotalVatGifts = 0;

        public List<CalculatorInfo> CommissionList = new List<CalculatorInfo>();
        protected decimal TotalHHPrices = 0;
        protected decimal TotalHHAdults = 0;
        protected decimal TotalHHChild = 0;
        protected decimal TotalHHBaby = 0;
        protected decimal TotalVatCommission = 0;

        #endregion
        private List<CalculatorInfo> _calculatorList = new List<CalculatorInfo>();
        private readonly CalculatorController _calculatorController = new CalculatorController();
        protected TourInfo tourInfo = new TourInfo();
        private TourInfo _tourInfo = new TourInfo();
        private readonly TourController _tourController = new TourController();
        //profitcalculator
        protected List<ProfitCalculatorInfo> profitCalculatorInfoList = new List<ProfitCalculatorInfo>();
        protected ProfitCalculatorInfo profitCalculatorInfo = new ProfitCalculatorInfo();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request.QueryString["TourId"]))
            {
                _calculatorList = _calculatorController.ListCalculator().Where(p => p.TourId == int.Parse(Request.QueryString["TourId"])).ToList();
                tourInfo = new TourController().GetTour(int.Parse(Request.QueryString["TourId"]));
               
                _tourInfo = tourInfo;

                profitCalculatorInfoList =
                    new ProfitCalculatorController().ListProfitCalculator()
                        .Where(p => p.TourId == int.Parse(Request.QueryString["TourId"]))
                        .ToList();
                profitCalculatorInfo.ProfitCalculatorId = -1;
                if (profitCalculatorInfoList.Count > 0)
                {
                    profitCalculatorInfo = profitCalculatorInfoList.First();

                    TotalSalePriceCaculatorAdults.Text = profitCalculatorInfo.PercentAdults.ToString();
                    TotalSalePriceCaculatorChild.Text = profitCalculatorInfo.PercentChild.ToString();
                    TotalSalePriceCaculatorBaby.Text = profitCalculatorInfo.PercentBaby.ToString();
                    TotalSalePriceCaculator.Text = profitCalculatorInfo.PercentTotal.ToString();
                    ChiPhiQuanLyDoanhNghiep.Text = profitCalculatorInfo.PriceOnCustomer.ToString();
                    ProfitNote1.Text = profitCalculatorInfo.Note1.ToString();
                    ProfitNote2.Text = profitCalculatorInfo.Note2.ToString();
                    ProfitNote3.Text = profitCalculatorInfo.Note3.ToString();
                    ProfitNote4.Text = profitCalculatorInfo.Note4.ToString();
                    ProfitNote5.Text = profitCalculatorInfo.Note5.ToString();
                    ProfitNote6.Text = profitCalculatorInfo.Note6.ToString();
                    ProfitNote7.Text = profitCalculatorInfo.Note7.ToString();
                    ProfitNote8.Text = profitCalculatorInfo.Note8.ToString();
                    ProfitNote9.Text = profitCalculatorInfo.Note9.ToString();
                    ProfitNote10.Text = profitCalculatorInfo.Note10.ToString();
                    ProfitNote11.Text = profitCalculatorInfo.Note11.ToString();
                    ProfitNote12.Text = profitCalculatorInfo.Note12.ToString();
                    ProfitNote13.Text = profitCalculatorInfo.Note13.ToString();
                    ProfitNote14.Text = profitCalculatorInfo.Note14.ToString();
                    ProfitNote15.Text = profitCalculatorInfo.Note15.ToString();
                    ProfitNote16.Text = profitCalculatorInfo.Note16.ToString();
                }
                #region         GoiHam
                LoadFlightArrivals();
                LoadSchedule();
                LoadScheduleStation();
                LoadConcern();
                LoadConcernStation();
                LoadScheduleCar();
                LoadSoChoCar();
                LoadConcernCar();
                LoadYearCar();
                LoadPartnarByPrice();
                LoadAddressDefault();
                LoadNational();
                LoadRestaurantType();
                LoadMenuType();
                //Visa
                LoadPartner();
                LoadVisaType();
                //Dich Vu Khac
                LoadLocationType();
                LoadNationalDVK();

                LoadLevel();
                LoadGender();
                LoadCity();
                LoadTravelGuide();

                LoadHotelType();

                LoadHotelTypeShip();
                LoadNationalShip();
                LoadScheduleShip();

                LoadGiftsType();

                LoadServiceType();

                LoadTime();
                RenderForm();
                #endregion
            }
            //if (_calculatorList.Count == 0) return;


        }
      
        private
            void RenderForm()
        {

            if (!String.IsNullOrEmpty(Request.QueryString["TourId"]))
            {
                //load info tour 
                #region load info tour
                lbQuantityAdultsTour.Text = tourInfo.QuantityAdult.ToString();
                lbQuantityChildTour.Text = tourInfo.QuantityChild.ToString();
                lbQuantityBabyTour.Text = tourInfo.QuantityBaby.ToString();
                lbBeginDateTour.Text = tourInfo.BeginDate.ToString("dd/MM/yyyy") + " -- ";
                lbBeginHourTour.Text = tourInfo.BeginDate.Hour.ToString() + ":";
                lbBeginMinuteTour.Text = tourInfo.BeginDate.Minute.ToString() + ": 00";
                lbEndDateTour.Text = tourInfo.EndDate.ToString("dd/MM/yyyy") + " -- ";
                lbEndHourTour.Text = tourInfo.EndDate.Hour.ToString() + ":";
                lbEndMinuteTour.Text = tourInfo.EndDate.Minute.ToString() + ": 00";
                lbTotalDayTour.Text = tourInfo.QuantityDay.ToString();
                lbTotalNightTour.Text = tourInfo.QuantityNight.ToString();
                #endregion
                #region Tinh Tong
                //load info calculator air
                TicketAirs = _calculatorList.Where(p => p.ItemType == 1).ToList();
                TotalTicketAirPricesAdults = TicketAirs.Sum(p => p.PriceAdults);
                TotalTicketAirPricesChild = TicketAirs.Sum(p => p.PriceChild);
                TotalTicketAirPricesBaby = TicketAirs.Sum(p => p.PriceBaby);
                TotalTicketAirPrices = TicketAirs.Sum(p => p.TotalPriceAir);
                TotalVatAir = (decimal)TicketAirs.Sum(p => p.Vat);

                //load info calculator car
                TicketCars = _calculatorList.Where(p => p.ItemType == 3).ToList();
                TotalTicketCarPrices = TicketCars.Sum(p => p.TotalPriceCar);
                var priceCarOnCustomer = (tourInfo.QuantityAdult + tourInfo.QuantityChild) != 0 ? TotalTicketCarPrices / (tourInfo.QuantityAdult + tourInfo.QuantityChild) : 0;
                TotalTicketCarPricesAdults = priceCarOnCustomer;
                TotalTicketCarPricesChild = priceCarOnCustomer;
                TotalVatCar = (decimal)TicketCars.Sum(p => p.Vat);

                //load info calculator station
                TicketStations = _calculatorList.Where(p => p.ItemType == 2).ToList();
                TotalTicketStationPricesAdults = TicketStations.Sum(p => p.PriceAdults);
                TotalTicketStationPricesChild = TicketStations.Sum(p => p.PriceChild);
                TotalTicketStationPricesBaby = TicketStations.Sum(p => p.PriceBaby);
                TotalTicketStationPrices = TicketStations.Sum(p => p.TotalPriceAir);
                TotalVatStation = (decimal)TicketStations.Sum(p => p.Vat);

                //Menu
                RestaurantList = _calculatorList.Where(p => p.ItemType == 4).ToList();
                TotalMenuAdults = RestaurantList.Sum(p => p.PriceAdults);
                TotalMenuChild = RestaurantList.Sum(p => p.PriceChild);
                TotalMenuBaby = RestaurantList.Sum(p => p.PriceBaby);
                TotalMenuPrices = RestaurantList.Sum(p => p.TotalPriceAir);
                TotalVatRestaurant = (decimal)RestaurantList.Sum(p => p.Vat);

                //khach san
                TicketHotel = _calculatorList.Where(p => p.ItemType == 5).ToList();
                TotalTicketHotelPricesAdults = TicketHotel.Sum(p => p.PriceAdults*p.CountNightHotel);
                TotalTicketHotelPricesChild = TicketHotel.Sum(p => p.PriceChild * p.CountNightHotel);
                TotalTicketHotelPricesBaby = TicketHotel.Sum(p => p.PriceBaby * p.CountNightHotel);
                TotalTicketHotelPrices = TicketHotel.Sum(p => p.TotalPriceHotel);
                TotalVatHotel = (decimal)TicketHotel.Sum(p => p.Vat);

                //tauthuy
                TicketShip = _calculatorList.Where(p => p.ItemType == 10).ToList();
                TotalTicketShipPricesAdults = TicketShip.Sum(p => p.PriceAdults * p.CountNightHotel);
                TotalTicketShipPricesChild = TicketShip.Sum(p => p.PriceChild * p.CountNightHotel);
                TotalTicketShipPricesBaby = TicketShip.Sum(p => p.PriceBaby * p.CountNightHotel);
                TotalTicketShipPrices = TicketShip.Sum(p => p.TotalPriceHotel);
                TotalVatShip = (decimal)TicketShip.Sum(p => p.Vat);

                //dich vu khac
                ServiceList = _calculatorList.Where(p => p.ItemType == 8).ToList();
                TotalDVKAdults = ServiceList.Sum(p => p.PriceAdults) + ServiceList.Sum(p => p.TranslateAdult) / (tourInfo.QuantityAdult + tourInfo.QuantityChild);
                TotalDVKChild = ServiceList.Sum(p => p.PriceChild) + ServiceList.Sum(p => p.TranslateAdult) / (tourInfo.QuantityAdult + tourInfo.QuantityChild);
                TotalDVKBaby = ServiceList.Sum(p => p.PriceBaby);
                TotalDVKPrices = ServiceList.Sum(p => p.TotalPriceService);
                TotalVatService = (decimal)ServiceList.Sum(p => p.Vat);

                // huong dan vien
                TravelGuideCashs = _calculatorList.Where(p => p.ItemType == 9).ToList();
                TotalTravelGuidePrices = TravelGuideCashs.Sum(p => p.TotalPriceTravelGuide);
                var priceTravelGuideOnCustomer = (tourInfo.QuantityAdult + tourInfo.QuantityChild) != 0 ? TotalTravelGuidePrices / (tourInfo.QuantityAdult + tourInfo.QuantityChild) : 0;
                TotalTravelGuidePricesAdults = priceTravelGuideOnCustomer;
                TotalTravelGuidePricesChild = priceTravelGuideOnCustomer;
                TotalVatTravelGuide = (decimal)TravelGuideCashs.Sum(p => p.Vat);

                //load info calculator insurance
                InsuranceList = _calculatorList.Where(p => p.ItemType == 7).ToList();
                TotalInsurancePricesAdults = InsuranceList.Sum(p => p.PriceAdults);
                TotalInsurancePricesChild = InsuranceList.Sum(p => p.PriceChild);
                TotalInsurancePricesBaby = InsuranceList.Sum(p => p.PriceBaby);
                TotalInsurancePrices = InsuranceList.Sum(p => p.TotalPriceAir);
                TotalVatInsurance = (decimal)InsuranceList.Sum(p => p.Vat);

                //Visa
                VisaList = _calculatorList.Where(p => p.ItemType == 6).ToList();
                TotalVisaAdults = VisaList.Sum(p => p.TotalPriceAdultsVisa);
                TotalVisaChild = VisaList.Sum(p => p.TotalPriceChildVisa);
                TotalVisaBaby = VisaList.Sum(p => p.TotalPriceBabyVisa);
                TotalVisaPrices = VisaList.Sum(p => p.TotalPriceVisa);
                TotalVatVisa = (decimal)VisaList.Sum(p => p.Vat);

                //qua tang
                GiftsList = _calculatorList.Where(p => p.ItemType == 13).ToList();
                TotalGiftsPrices = GiftsList.Sum(p => p.TotalPriceGifts);
                TotalGiftsPricesAdults = GiftsList.Sum(p => p.TotalPriceAdultsGifts);
                TotalGiftsPricesChild = GiftsList.Sum(p => p.TotalPriceChildGifts);
                TotalGiftsPricesBaby = GiftsList.Sum(p => p.TotalPriceBabyGifts);
                TotalVatGifts = (decimal)GiftsList.Sum(p => p.Vat);

                //hoa hoong 
                CommissionList = _calculatorList.Where(p => p.ItemType == 11).ToList();
                TotalHHAdults = CommissionList.Sum(p => p.PriceAdults);
                TotalHHChild = CommissionList.Sum(p => p.PriceChild);
                TotalHHBaby = CommissionList.Sum(p => p.PriceBaby);
                TotalHHPrices = CommissionList.Sum(p => p.TotalPriceAir);
                TotalVatCommission = (decimal)CommissionList.Sum(p => p.Vat);

                #endregion
            }
        }
        protected void lbtSave_Click(object sender, EventArgs e)
        {
            SaveData();
            //RedirectLink();
        }
        protected void lbtClose_Click(object sender, EventArgs e)
        {
            //RedirectLink();
        }

        #region Load Thong Tin co Ban
        protected void SaveData()
        {
            _tourInfo.QuantityAdult = int.Parse(txtQuantityAdultsTour.Text);
            _tourInfo.QuantityChild = int.Parse(txtQuantityChildTour.Text);

            if (txtQuantityBabyTour.Text.Equals(""))
            {
                _tourInfo.QuantityBaby = 0;
            }
            else
            {
                _tourInfo.QuantityBaby = int.Parse(txtQuantityBabyTour.Text);
            }
            if (!String.IsNullOrEmpty(dteBeginDateTour.Value))
            {
                var beginDate = Convert.ToDateTime(dteBeginDateTour.Value);
                _tourInfo.BeginDate = new DateTime(beginDate.Year, beginDate.Month, beginDate.Day, int.Parse(ddlBeginHourTour.SelectedValue), int.Parse(ddlBeginMinuteTour.SelectedValue), 0);
            }
            if (!String.IsNullOrEmpty(dteEndDateTour.Value))
            {
                var endDate = Convert.ToDateTime(dteEndDateTour.Value);
                _tourInfo.EndDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, int.Parse(ddlEndHourTour.SelectedValue), int.Parse(ddlEndMinuteTour.SelectedValue), 0);
            }
            _tourInfo.QuantityDay = int.Parse(txtTotalDayTour.Text);
            _tourInfo.QuantityNight = int.Parse(txtTotalNightTour.Text);


            _tourInfo.UpdatedBy = UserId;
            _tourInfo.UpdatedDate = DateTime.Now;
            _tourController.UpdateTour(_tourInfo);


            Response.Redirect("/Pages/BangChietTinh.aspx?TourId=" + int.Parse(Request.QueryString["TourId"]));
        }
        private void LoadTime()
        {
            for (var i = 0; i < 24; i++)
            {
                //var hour = i < 10 ? "0" + i : i.ToString();
                ddlBeginHourTour.Items.Add(new ListItem(i.ToString(), i.ToString()));
                ddlEndHourTour.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
            for (var i = 0; i < 60; i++)
            {
                //var minute = i < 10 ? "0" + i : i.ToString();
                ddlBeginMinuteTour.Items.Add(new ListItem(i.ToString(), i.ToString()));
                ddlEndMinuteTour.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
        }
        private void LoadFlightArrivals()
        {
            var ds = new DataSet();
            ds.ReadXml(MapPath("~/xml/FlightArrivals.xml"));
            var dv = ds.Tables["FlightArrivals"].DefaultView;
            ddlFlightArrivalsAir.DataTextField = "Name";
            ddlFlightArrivalsAir.DataValueField = "ID";
            ddlFlightArrivalsAir.DataSource = dv;
            ddlFlightArrivalsAir.DataBind();
            ddlFlightArrivalsAir.Items.Insert(0, new ListItem("--- Chọn lượt bay ---", "-1"));

            ddlFlightArrivalsStation.DataTextField = "Name";
            ddlFlightArrivalsStation.DataValueField = "ID";
            ddlFlightArrivalsStation.DataSource = dv;
            ddlFlightArrivalsStation.DataBind();
            ddlFlightArrivalsStation.Items.Insert(0, new ListItem("--- Chọn lượt bay ---", "-1"));
        }
        private void LoadSchedule()
        {
            ddlScheduleAir.DataSource =
                new ScheduleController().ListSchedule()
                    .Where(p => p.Status == (int)Globals.DocumentStatus.Use && p.ScheduleType == 1)
                    .OrderBy(p => p.ScheduleName);

            ddlScheduleAir.DataTextField = "ScheduleName";
            ddlScheduleAir.DataValueField = "ScheduleId";
            ddlScheduleAir.DataBind();

            ddlScheduleAir.Items.Insert(0, new ListItem("--- Chọn lịch trình ---", "-1"));
        }

        private void LoadScheduleStation()
        {
            ddlScheduleStation.DataSource =
                new ScheduleController().ListSchedule()
                    .Where(p => p.Status == (int)Globals.DocumentStatus.Use && p.ScheduleType == 2)
                    .OrderBy(p => p.ScheduleName);

            ddlScheduleStation.DataTextField = "ScheduleName";
            ddlScheduleStation.DataValueField = "ScheduleId";
            ddlScheduleStation.DataBind();

            ddlScheduleStation.Items.Insert(0, new ListItem("--- Chọn lịch trình ---", "-1"));
        }
        private void LoadConcern()
        {
            ddlConcernAir.DataSource = new ConcernController().ListConcernByStatus((int)Globals.DocumentStatus.Use).Where(p => p.ConcernType == 1).OrderBy(p => p.ConcernFullName);
            ddlConcernAir.DataTextField = "ConcernFullName";
            ddlConcernAir.DataValueField = "ConcernId";
            ddlConcernAir.DataBind();

            ddlConcernAir.Items.Insert(0, new ListItem("--- Chọn hãng---", "-1"));

        }

        private void LoadConcernStation()
        {
            ddlConcernStation.DataSource = new ConcernController().ListConcernByStatus((int)Globals.DocumentStatus.Use).Where(p => p.ConcernType == 2).OrderBy(p => p.ConcernFullName);
            ddlConcernStation.DataTextField = "ConcernFullName";
            ddlConcernStation.DataValueField = "ConcernId";
            ddlConcernStation.DataBind();

            ddlConcernStation.Items.Insert(0, new ListItem("--- Chọn hãng---", "-1"));


        }
        private void LoadScheduleCar()
        {
            ddlScheduleCar.DataSource =
                new ScheduleController().ListSchedule()
                    .Where(p => p.Status == (int)Globals.DocumentStatus.Use && p.ScheduleType == 4)
                    .OrderBy(p => p.ScheduleName);

            ddlScheduleCar.DataTextField = "ScheduleName";
            ddlScheduleCar.DataValueField = "ScheduleId";
            ddlScheduleCar.DataBind();

            ddlScheduleCar.Items.Insert(0, new ListItem("--- Chọn lịch trình ---", "-1"));
        }
        private void LoadSoChoCar()
        {
            ddlSoChoCar.Items.Add("4");
            ddlSoChoCar.Items.Add("5");
            ddlSoChoCar.Items.Add("7");
            ddlSoChoCar.Items.Add("8");
            ddlSoChoCar.Items.Add("10");
            ddlSoChoCar.Items.Add("16");
            ddlSoChoCar.Items.Add("30");
            ddlSoChoCar.Items.Insert(0, new ListItem("--- Chọn số chỗ ---", "-1"));
        }
        private void LoadConcernCar()
        {
            ddlConcernCar.DataSource = new ConcernController().ListConcernByStatus((int)Globals.DocumentStatus.Use).Where(p => p.ConcernType == 3).OrderBy(p => p.ConcernFullName);
            ddlConcernCar.DataTextField = "ConcernFullName";
            ddlConcernCar.DataValueField = "ConcernId";
            ddlConcernCar.DataBind();

            ddlConcernCar.Items.Insert(0, new ListItem("--- Chọn hãng---", "-1"));

        }
        private void LoadYearCar()
        {
            int year = DateTime.Now.Year;
            for (int i = 0; i >= -20; i--)
            {
                ddlYearCar.Items.Add((year + i).ToString());
            }
            ddlYearCar.Items.Insert(0, new ListItem("--- Chọn năm ---", "-1"));
        }
        public void LoadPartnarByPrice()
        {
            ddlPartnerInsurance.DataSource = new PartnerController().ListInsurancePartner().OrderBy(p => p.PartnerName);
            ddlPartnerInsurance.DataValueField = "PartnerId";
            ddlPartnerInsurance.DataTextField = "PartnerName";
            ddlPartnerInsurance.DataBind();

            ddlPartnerInsurance.Items.Insert(0, new ListItem("--Chọn nhà cung cấp--", "-1"));

        }
        private void LoadAddressDefault()
        {
            ddlNationalMenu.Items.Insert(0, new ListItem("--- Chọn quốc gia ---", "-1"));
            ddlCityMenu.Items.Insert(0, new ListItem("--- Chọn tỉnh/thành phố ---", "-1"));
            ddlRestaurantMenu.Items.Insert(0, new ListItem("--- Chọn nhà hàng ---", "-1"));
            ddlRestaurantTypeMenu.Items.Insert(0, new ListItem("--- Chọn loại nhà hàng ---", "-1"));
            ddlMenuMenu.Items.Insert(0, new ListItem("--- Chọn thực đơn ---", "-1"));
            ddlMenuTypeMenu.Items.Insert(0, new ListItem("--- Chọn loại thực đơn ---", "-1"));

            ddlVisaNameVisa.Items.Insert(0, new ListItem("--Chọn Visa --", "-1"));
        }
        public void LoadNational()
        {
            ddlNationalMenu.DataSource = new NationalController().ListNational().OrderBy(p => p.NationalName);
            ddlNationalMenu.DataValueField = "NationalId";
            ddlNationalMenu.DataTextField = "NationalName";
            ddlNationalMenu.DataBind();
            ddlNationalMenu.Items.Insert(0, new ListItem("--Chọn quốc gia--", "-1"));

            ddlNationalHotel.DataSource = new NationalController().ListNational().OrderBy(p => p.NationalName);
            ddlNationalHotel.DataValueField = "NationalId";
            ddlNationalHotel.DataTextField = "NationalName";
            ddlNationalHotel.DataBind();
            ddlNationalHotel.Items.Insert(0, new ListItem("--Chọn quốc gia--", "-1"));
        }
        private void LoadRestaurantType()
        {
            ddlRestaurantTypeMenu.DataSource = new RestaurantTypeController().ListRestaurantType()
                .Where(p => p.Status == (int)Globals.DocumentStatus.Use)
                .OrderBy(p => p.RestaurantTypeName).ToList();
            ddlRestaurantTypeMenu.DataTextField = "RestaurantTypeName";
            ddlRestaurantTypeMenu.DataValueField = "RestaurantTypeId";
            ddlRestaurantTypeMenu.DataBind();
            ddlRestaurantTypeMenu.Items.Insert(0, new ListItem("--- Chọn loại nhà hàng ---", "-1"));
        }
        private void LoadMenuType()
        {
            ddlMenuTypeMenu.DataSource = new MenuTypeController().ListMenuType()
                .Where(p => p.Status == (int)Globals.DocumentStatus.Use)
                .OrderBy(p => p.MenuTypeName);
            ddlMenuTypeMenu.DataTextField = "MenuTypeName";
            ddlMenuTypeMenu.DataValueField = "MenuTypeId";
            ddlMenuTypeMenu.DataBind();
            ddlMenuTypeMenu.Items.Insert(0, new ListItem("--- Chọn loại menu ---", "-1"));
        }
        //Visa
        public void LoadPartner()
        {
            ddlPartnerNameVisa.DataSource = new PartnerController().ListPartner().OrderBy(p => p.PartnerName);
            ddlPartnerNameVisa.DataValueField = "PartnerId";
            ddlPartnerNameVisa.DataTextField = "PartnerName";
            ddlPartnerNameVisa.DataBind();
            ddlPartnerNameVisa.Items.Insert(0, new ListItem("--Chọn nhà cung cấp --", "-1"));

            ddlPartnerDVK.DataSource = new PartnerController().ListPartner().OrderBy(p => p.PartnerName);
            ddlPartnerDVK.DataValueField = "PartnerId";
            ddlPartnerDVK.DataTextField = "PartnerName";
            ddlPartnerDVK.DataBind();
            ddlPartnerDVK.Items.Insert(0, new ListItem("--Chọn nhà cung cấp --", "-1"));
        }
        public void LoadVisaType()
        {
            ddlVisaTypeNameVisa.DataSource = new VisaTypeController().ListVisaType().OrderBy(p => p.VisaTypeName);
            ddlVisaTypeNameVisa.DataValueField = "VisaTypeId";
            ddlVisaTypeNameVisa.DataTextField = "VisaTypeName";
            ddlVisaTypeNameVisa.DataBind();
            ddlVisaTypeNameVisa.Items.Insert(0, new ListItem("--Chọn  loại Visa --", "-1"));
        }

        //Dich vu khac
        public void LoadLocationType()
        {
            ddlLocationTypeDVK.DataSource = new LocationTypeController().ListLocationType().OrderBy(p => p.LocationTypeName);
            ddlLocationTypeDVK.DataValueField = "LocationTypeId";
            ddlLocationTypeDVK.DataTextField = "LocationTypeName";
            ddlLocationTypeDVK.DataBind();
            ddlLocationTypeDVK.Items.Insert(0, new ListItem("--Chọn  loại Visa --", "-1"));
        }
        public void LoadNationalDVK()
        {
            ddlNationalDVK.DataSource = new NationalController().ListNational().OrderBy(p => p.NationalName);
            ddlNationalDVK.DataValueField = "NationalId";
            ddlNationalDVK.DataTextField = "NationalName";
            ddlNationalDVK.DataBind();
            ddlNationalDVK.Items.Insert(0, new ListItem("--Chọn quốc gia--", "-1"));
        }
        private void LoadLevel()
        {
            var ds = new DataSet();
            ds.ReadXml(MapPath("~/xml/Level.xml"));
            var dv = ds.Tables["Level"].DefaultView;
            ddlLevelTravelGuide.DataTextField = "Name";
            ddlLevelTravelGuide.DataValueField = "ID";
            ddlLevelTravelGuide.DataSource = dv;
            ddlLevelTravelGuide.DataBind();

            ddlLevelTravelGuide.Items.Insert(0, new ListItem("--- Chọn trình độ ---", "-1"));

        }
        private void LoadGender()
        {

            ddlGenderTravelGuide.Items.Insert(0, new ListItem("--- Chọn gioi tinh---", "-1"));
            ddlGenderTravelGuide.Items.Insert(1, new ListItem("Nam", "Nam"));
            ddlGenderTravelGuide.Items.Insert(2, new ListItem("Nữ", "Nữ"));
        }
        private void LoadCity()
        {
            ddlLanguageTravelGuide.DataSource = new LanguageController().ListLanguage();
            ddlLanguageTravelGuide.DataTextField = "LanguageName";
            ddlLanguageTravelGuide.DataValueField = "LanguageId";
            ddlLanguageTravelGuide.DataBind();

            ddlLanguageTravelGuide.Items.Insert(0, new ListItem("--- Chọn Ngon ngu ---", "-1"));
        }
        private void LoadTravelGuide()
        {

            ddlTravelGuideType.Items.Insert(0, new ListItem("--- Chọn loai HDV---", "-1"));
            ddlTravelGuideType.Items.Insert(1, new ListItem("Suốt tuyến", "Suốt tuyến"));
            ddlTravelGuideType.Items.Insert(2, new ListItem("Local", "Local"));
        }
        public void LoadHotelType()
        {
            ddlHotelType.DataSource = new HotelTypeController().ListHotelType().OrderBy(p => p.HotelTypeName);
            ddlHotelType.DataValueField = "HotelTypeId";
            ddlHotelType.DataTextField = "HotelTypeName";
            ddlHotelType.DataBind();

            ddlHotelType.Items.Insert(0, new ListItem("--Chọn loại--", "-1"));
        }
        public void LoadNationalShip()
        {
            ddlNationalShip.DataSource = new NationalController().ListNational().OrderBy(p => p.NationalName);
            ddlNationalShip.DataValueField = "NationalId";
            ddlNationalShip.DataTextField = "NationalName";
            ddlNationalShip.DataBind();
            ddlNationalShip.Items.Insert(0, new ListItem("--Chọn quốc gia--", "-1"));
        }
        public void LoadHotelTypeShip()
        {
            ddlHotelTypeShip.DataSource = new HotelTypeController().ListHotelType().OrderBy(p => p.HotelTypeName);
            ddlHotelTypeShip.DataValueField = "HotelTypeId";
            ddlHotelTypeShip.DataTextField = "HotelTypeName";
            ddlHotelTypeShip.DataBind();
            ddlHotelTypeShip.Items.Insert(0, new ListItem("--Chọn loại--", "-1"));
        }
        private void LoadScheduleShip()
        {
            ddlScheduleShip.DataSource =
                new ScheduleController().ListSchedule()
                    .Where(p => p.Status == (int)Globals.DocumentStatus.Use && p.ScheduleType == 3)
                    .OrderBy(p => p.ScheduleName);

            ddlScheduleShip.DataTextField = "ScheduleName";
            ddlScheduleShip.DataValueField = "ScheduleId";
            ddlScheduleShip.DataBind();
            ddlScheduleShip.Items.Insert(0, new ListItem("--- Chọn lịch trình ---", "-1"));
        }

        public void LoadGiftsType()
        {
            ddlGiftsType.DataSource = new GiftsTypeController().ListGiftsType().OrderBy(p => p.GiftsTypeName);
            ddlGiftsType.DataValueField = "GiftsTypeId";
            ddlGiftsType.DataTextField = "GiftsTypeName";
            ddlGiftsType.DataBind();
            ddlGiftsType.Items.Insert(0, new ListItem("--Chọn loại quà--", "-1"));
        }
        private void LoadServiceType()
        {
            ddlServiceType.Items.Insert(0, new ListItem("--- Chọn loai ve---", "-1"));
            ddlServiceType.Items.Insert(1, new ListItem("Vé lẻ", "1"));
            ddlServiceType.Items.Insert(2, new ListItem("Vé đoàn", "2"));
        }
        #endregion

    }
}